//  ========== 
//  = 合同 业务JS = 
//  ==========

var Main = function(){
	mui.init({
		swipeBack:true 		//启用右滑关闭功能
	});
	this.init();
	this.loadData();
};
Main.prototype = {
	init : function(){
		mui('.mui-scroll-wrapper').scroll({
					indicators: true //是否显示滚动条
		});
		var _this = this;
	
		_this.eventInit()
		
	},
	eventInit : function(){//绑定事件

	},
	_itemBindTap : function(){//列表绑定点击事件
		
	},
   
	//内容列表
	loadData : function(page,_callback){
		var _setData = function(data){
			var pbi = data.pbi;
			var plan = data.plan;
			var bpCustMember = data.bpCustMember;
            $('.contractNo').html(Util.safeString(pbi.contractNo));
            $('.truename').html(Util.safeString(bpCustMember.truename));
            $('.truename1').html('甲方：'+Util.safeString(bpCustMember.truename));
            $('.loginname').html(Util.safeString(bpCustMember.loginname));
            $('.cardcode').html(Util.safeString(bpCustMember.cardcode));
            $('.mmName').html(Util.safeString(pbi.mmName));
            if(pbi.promisYearRate){
                $('.promisYearRate').html(pbi.promisYearRate+'%');
            }else{
            	$('.promisYearRate').html('');
            }
            $('.buyDatetime').html(Util.safeString(pbi.buyDatetime));
            $('.buyMoney').html(Util.safeString(pbi.buyMoney));
            if(plan.investlimit){
             $('.investlimit').html((plan.investlimit>0?plan.investlimit:'0')+'月');
            }else{
            $('.investlimit').html('');	
            }
            if(pbi.investType){
            $('.investType').html(pbi.investType==1?'收益再投资':'提取主账户');
            }else{
            $('.investType').html('');	
            }
            if(plan.startinInterestTime){
            $('.startinInterestTime').html(Util.time.formatDate(new Date(Util.safeString(plan.startinInterestTime)),'yyyy-MM-dd'));
            }else{
            $('.startinInterestTime').html('');	
            }
            if(plan.lockingEndDate){
            $('.lockingEndDate').html(Util.time.formatDate(new Date(Util.safeString(plan.lockingEndDate)),'yyyy-MM-dd'));
            }else{
            $('.lockingEndDate').html('');	
            }
            $('.nowDate').html(Util.time.formatDate(new Date(),'yyyy-MM-dd'));
		}
		
		//Util.loading();
		if(Util.requestURL('orderId') == ''){
			$('.mui-title').html('服务协议');
			var data = {};
				data.pbi = {};
			    data.plan = {};
			    data.bpCustMember = {};
			_setData(data)
			return;
		}
		var _this = this;
		var param = {
				isMobile:1,
				memberId:Util.getLoginUser().memberId,
				orderId:Util.requestURL('orderId')
				};
	    
		var url = server_url+'/creditFlow/financingAgency/buyInfoContractPlManageMoneyPlan.do';
		$.getJSON(url,param  ,function(data){
			var _html = '';
			if(data.success){
				_setData(data);
            }			
//            Util.closeLoading();
             
             if($.isFunction(_callback)){
             	_callback();
             }
		});
		
	}
	
}
